<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>22_DOM2-低级浏览器-绑定方法2-解绑</title>
        <style>
            div {
                width: 100px;
                height: 100px;
                background-color: aqua;
            }
        </style>
    </head>
    <body>
        <div id="d1">绑定</div>
        <button id="btn">解绑</button>

        <script>
            var div = document.getElementById('d1');

            function f1(){
                console.log(1111);
            }

            div.attachEvent('onclick',f1);

            var btn = document.getElementById('btn');

            btn.attachEvent('onclick',function(){
                div.detachEvent('onclick',f1);
            })
        </script>
    </body>
</html>